package com.solidtrust.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
	private static final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
	private static final SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
	private static final SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年");
	private static final SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy.M");
	
	
	public static Date parseMonth(String s){
		Date d = string2Date(s);
		if(d == null){
			d = string2Date1(s);
		}
		return d;
	}
	
	public static Date string2Date(String s){
		try {
			return sdf.parse(s);
		} catch (ParseException e) {
		}
		return null;
	}
	
	public static Date string2Date1(String s){
		try {
			return sdf1.parse(s);
		} catch (ParseException e) {
		}
		return null;
	}
	
	public static String date2String1(Date d){
		return sdf1.format(d);
	}
	
	public static String date2String2(Date d){
		return sdf2.format(d);
	}
	
	public static Date string2Date2(String s){
		try {
			return sdf2.parse(s);
		} catch (ParseException e) {
		}
		return null;
	}
	public static Date string2Date3(String s){
		try {
			return sdf3.parse(s);
		} catch (ParseException e) {
		}
		return null;
	}
	public static Date string2Date4(String s){
		try {
			return sdf4.parse(s);
		} catch (ParseException e) {
		}
		return null;
	}
}
